package com.etlmaster.executor.steps.rowprocessor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.etlmaster.executor.Step;
import com.etlmaster.executor.StepMeta;
import com.etlmaster.executor.annotation.StepInstruction;
import com.etlmaster.executor.utils.StepState;

import freemarker.core.FreeMarkerTemplate;

@StepInstruction("rowProcessrestReader")

public class RestFulReaderStep extends Step{

	private RestFulReaderStepMeta meta;
	public RestFulReaderStep(StepMeta meta) {
		super(meta);
		this.meta=(RestFulReaderStepMeta) meta;
	}

	@Override
	protected int handle() {
		Map<String,String> map=new HashMap<String,String>();
		map.put("type", "reader");
		map.put("id", meta.getId());
		map.put("name", meta.getName());
		map.put("code", meta.getId());
		map.put("class", "com.etlmaster.rowprocessor.steps.RestServerProvider");
		StringBuilder sb=new StringBuilder();
		sb.append("{}");
		map.put("param", sb.toString());
		String rowstep=FreeMarkerTemplate.getFpl("plugin",map);
		List<String> rowSteps=new ArrayList<String>();
		rowSteps.add(rowstep);
		meta.getStepState().getReturnValue().put("jobJson", rowSteps);
		meta.log("INFO","生成{}配置成功",meta.getName());
		return StepState.RUNNING_SUCCESSED;
	}

	@Override
	public boolean stop() {
		// TODO Auto-generated method stub
		return false;
	}

}
